package com.pattern.structure.proxy;

import sun.reflect.generics.tree.VoidDescriptor;

/**
 * @author yangguanzan
 * @date 3/31/22
 * @description
 */
public class GamePlayer implements IGamePlayer {
    private String name;
    private int level;

    public GamePlayer(GamePlayerProxy proxy, String name) throws Exception {
        //指定代理对象建立真实对象
        if(null ==proxy ){
            throw new Exception("不能创建真实角色，必须通过代理创建！");
        }
        this.name = name;
        this.level = 0;
    }

    @Override
    public void login(String name, String password) {
        //TODO 实现登陆验证

        System.out.println("登录名为："+name+"的用户："+this.name+"登录成功！");
    }

    @Override
    public void killBoss() {
        System.out.println("打怪");
    }

    @Override
    public void upgrade() {
        this.level++;
        System.out.println("每次升一级");
    }

    @Override
    public int getLevel() {
        return this.level;
    }
}
